package com.example.chenduoyun.safe.activity;

/**
 * @author cdy
 */

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.chenduoyun.safe.R;
import com.example.chenduoyun.safe.utils.ConstantValue;
import com.example.chenduoyun.safe.utils.SpUtils;

public class MobileSafeActivity extends AppCompatActivity {
    private TextView mReset,tvSafeNumber;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        boolean setup_over = SpUtils.getBoolean(this, ConstantValue.SETUP_OVER, false);
        if(setup_over){
            setContentView(R.layout.activity_mobile_safe);
        }else{
            Intent intent = new Intent(this, Setup1Activity.class);
            startActivity(intent);
            finish();
        }
        initUI();
        initData();
        mReset.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SpUtils.putBoolean(getApplicationContext(),ConstantValue.SETUP_OVER,false);
                Intent intent = new Intent(getApplicationContext(), Setup1Activity.class);
                startActivity(intent);
                finish();
            }
        });
    }

    private void initData() {
        String phone= SpUtils.getString(this,ConstantValue.CONTACT_PHONE,
                "");
        tvSafeNumber.setText(phone);
    }

    private void initUI() {
        tvSafeNumber=findViewById(R.id.tv_safe_number);
        mReset=findViewById(R.id.tv_reset);
    }
}
